package net.Reality.Android.Ant;

import java.util.Vector;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class ImageLoder 
{
	private static ImageLoder loder = null;
	
	Context context;
	
	Bitmap background;
	Bitmap enter;
	
	Vector<Bitmap> stones = new Vector<Bitmap>();
	Vector<Bitmap> ants = new Vector<Bitmap>();
	
	AntObject tunnel;
	AntObject entrance;
	AntObject oval;
	AntObject knee;
	
	
	
	private ImageLoder(Context context)
	{
		this.context = context;
		loadBackground();
		loadEnter();
		loadStones();
		loadAnts();
		loadTunnel();
		loadOval();
		loadKnee();
		loadEntrance();
	}
	
	public static ImageLoder getInstance(Context context)
	{
		if(loder == null) 
			loder = new ImageLoder(context);
		
		return loder;
	}
	
	private void loadBackground()
	{
		background = BitmapFactory.decodeResource(context.getResources(), R.drawable.background_dark);
	}
	private void loadEnter()
	{
		enter = BitmapFactory.decodeResource(context.getResources(), R.drawable.enter);
	}
	
	private void loadStones()
	{
		stones.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.stone1));
		stones.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.stone2));
		stones.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.stone3));
		stones.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.stone4));
		stones.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.stone5));
	}
	
	private void loadTunnel()
	{
		tunnel = new AntObject(null, 
							   BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_4_icon),
							   context.getString(R.string.object_name_tunnel), "T_OBJECT");
		
		tunnel.setHorizontal(null, 
				   			 BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_4_icon),
				   			 context.getString(R.string.object_name_horizontal), "T_H_OBJECT");
			tunnel.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_2), 
		   			 											BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_2_icon),
		   			 											context.getString(R.string.object_name_size_2), "T_H_S_2"));
			tunnel.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_4), 
																BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_4_icon),
																context.getString(R.string.object_name_size_4), "T_H_S_4"));
			tunnel.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_6), 
																BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_horizontal_6_icon),
																context.getString(R.string.object_name_size_6), "T_H_S_6"));
			
		tunnel.setVertical(null, 
						   BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_4_icon),
						   context.getString(R.string.object_name_vertical), "T_V_OBJECT");
			tunnel.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_2), 
															  BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_2_icon),
															  context.getString(R.string.object_name_size_2), "T_V_S_2"));
			tunnel.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_4), 
					  										  BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_4_icon),
					  										  context.getString(R.string.object_name_size_4), "T_V_S_4"));
			tunnel.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_6), 
															  BitmapFactory.decodeResource(context.getResources(),R.drawable.tunnel_vertical_6_icon),
															  context.getString(R.string.object_name_size_6), "T_V_S_6"));
			
		tunnel.setAngular(null, 
				   		  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
				   		  context.getString(R.string.object_name_angular), "T_A_OBJECT");
			tunnel.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
			   		  										 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
			   		  										 context.getString(R.string.object_name_size_2), "T_A_S_2_OBJECT"));
			tunnel.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
			   		  										 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
			   		  									     context.getString(R.string.object_name_size_4), "T_A_S_4_OBJECT"));
			tunnel.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
			   		  										 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
			   		  										 context.getString(R.string.object_name_size_6), "T_A_S_6_OBJECT"));
		
	}
	
	private void loadEntrance()
	{
		entrance = new AntObject(null, 
				   				 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
				   				context.getString(R.string.object_name_entrance), "E_OBJECT");
		
		entrance.setHorizontal(null, 
	   			 			   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
	   			 			   context.getString(R.string.object_name_horizontal), "E_H_OBJECT");
			entrance.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
												 			      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
												 			      context.getString(R.string.object_name_size_2), "E_H_S_2_OBJECT"));
			entrance.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
		 			   											  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
		 			   											  context.getString(R.string.object_name_size_4), "E_H_S_4_OBJECT"));
			entrance.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
		 			   											  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
		 			   											  context.getString(R.string.object_name_size_6), "E_H_S_6_OBJECT"));
			
		entrance.setVertical(null, 
	 			   			 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
	 			   			 context.getString(R.string.object_name_vertical), "E_V_OBJECT");
			entrance.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
																  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
																  context.getString(R.string.object_name_size_2), "E_V_S_2_OBJECT"));
			entrance.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
					  											  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
					  											  context.getString(R.string.object_name_size_4), "E_V_S_4_OBJECT"));
			entrance.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
					  											  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
					  											  context.getString(R.string.object_name_size_6), "E_V_S_6_OBJECT"));

		entrance.setAngular(null, 
	 			   			BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
	 			   			context.getString(R.string.object_name_angular), "E_A_OBJECT");
			entrance.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
																  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
																  context.getString(R.string.object_name_size_2), "E_A_S_2_OBJECT"));
			entrance.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
					  											  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
					  											  context.getString(R.string.object_name_size_4), "E_A_S_4_OBJECT"));
			entrance.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
					  											  BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
					  											  context.getString(R.string.object_name_size_6), "E_A_S_6_OBJECT"));
	}
	
	private void loadOval()
	{
		oval = new AntObject(null, 
  				 			 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
  				 			context.getString(R.string.object_name_oval), "O_OBJECT");
		
		oval.setHorizontal(null, 
	 			   		   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
	 			   		   context.getString(R.string.object_name_horizontal), "O_H_OBJECT");
			oval.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
				  										      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
				  										      context.getString(R.string.object_name_size_2), "O_H_S_2_OBJECT"));
			oval.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														      context.getString(R.string.object_name_size_4), "O_H_S_4_OBJECT"));
			oval.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														      context.getString(R.string.object_name_size_6), "O_H_S_6_OBJECT"));

		oval.setVertical(null, 
	 			   		 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
	 			   		 context.getString(R.string.object_name_vertical), "O_V_OBJECT");
			oval.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														    BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														    context.getString(R.string.object_name_size_2), "O_V_S_2_OBJECT"));
			oval.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														    BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														    context.getString(R.string.object_name_size_4), "O_V_S_4_OBJECT"));
			oval.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														    BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														    context.getString(R.string.object_name_size_6), "O_V_S_6_OBJECT"));
			
		oval.setAngular(null, 
	 			   		BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
	 			   		context.getString(R.string.object_name_angular), "O_A_OBJECT");
			oval.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														   context.getString(R.string.object_name_size_2), "O_A_S_2_OBJECT"));
			oval.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														   context.getString(R.string.object_name_size_4), "O_A_S_4_OBJECT"));
			oval.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
														   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
														   context.getString(R.string.object_name_size_6), "O_A_S_6_OBJECT"));
	}
	
	private void loadKnee()
	{
		knee = new AntObject(null, 
		 			 		 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
		 			 		context.getString(R.string.object_name_knee), "K_OBJECT");

			knee.setHorizontal(null, 
				   		   	   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
				   		   	   context.getString(R.string.object_name_horizontal), "K_H_OBJECT");
				knee.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
					  										      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
					  										      context.getString(R.string.object_name_size_2), "K_H_S_2_OBJECT"));
				knee.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															      context.getString(R.string.object_name_size_4), "K_H_S_4_OBJECT"));
				knee.getHorizontal().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															      BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															      context.getString(R.string.object_name_size_6), "K_H_S_6_OBJECT"));
			
			knee.setVertical(null, 
				   		 	 BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
				   		 	 context.getString(R.string.object_name_vertical), "K_V_OBJECT");
				knee.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															    BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															    context.getString(R.string.object_name_size_2), "K_H_S_2_OBJECT"));
				knee.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															    BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															    context.getString(R.string.object_name_size_4), "K_H_S_4_OBJECT"));
				knee.getVertical().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															    BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															    context.getString(R.string.object_name_size_6), "K_H_S_6_OBJECT"));
			
			knee.setAngular(null, 
				   			BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
				   			context.getString(R.string.object_name_angular), "K_A_OBJECT");
				knee.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															   context.getString(R.string.object_name_size_2), "K_A_S_2_OBJECT"));
				knee.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															   context.getString(R.string.object_name_size_4), "K_A_S_4_OBJECT"));
				knee.getAngular().getSizes().add(new AntObject(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0), 
															   BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0),
															   context.getString(R.string.object_name_size_6), "K_A_S_6_OBJECT"));
	}
	
	private void loadAnts()
	{
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant0));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant1));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant2));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant3));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant4));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant5));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant6));
		ants.add(BitmapFactory.decodeResource(context.getResources(),R.drawable.ant7));
	}
	
	public Bitmap getBackground()
	{
		return background;
	}
	
	public Bitmap getEnter()
	{
		return enter;
	}
	
	public Vector<Bitmap> getStones()
	{
		return stones;
	}
	
	
	public Vector<Bitmap> getAnts()
	{
		return ants;
	}
	
	public AntObject getTunnel()
	{
		return tunnel;
	}
	
	public AntObject getEntrance()
	{
		return entrance;
	}
	
	public AntObject getOval()
	{
		return oval;
	}
	
	public AntObject getKnee()
	{
		return knee;
	}
	
	public AntObject getFromTable(int table)
	{
		switch(table)
		{
			case 0: return tunnel;
			case 1: return entrance;
			case 2: return oval;
			case 3: return knee;
		}
		
		return null;
	}
	
	public void deleteAll()
	{
		background = null;
		enter = null;
		
		stones = null;
		ants = null;
		
		tunnel = null;
		entrance = null;
		oval = null;
		knee = null;
		
		loder = null;
	}
}
